package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.last.PcLastStockRequest;
import com.alks.function.data.request.last.PcSoleStockMessageRequest;
import com.alks.function.data.request.last.SoleSupportingInformationRequest;
import com.alks.function.service.PcLastStockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.ExecutionException;

/**
 * @author:xxxxx
 * @create: 2023-07-25 09:56
 * @Description: 底仓入库账目查询
 */
@ApiRestController("/last")
@Api(value = "荣阳工厂查询" ,tags = {"总经办-底仓工厂查询模块"})
public class PcLastStockController {
    @Autowired
    PcLastStockService pcLastStockService;
    @ApiOperation(value = "底仓指令查询")
    @PostMapping("/listLastStock")
    @WebLogger
    public ResponseInfo listLastStock(@RequestBody PcLastStockRequest request){
        return pcLastStockService.listLastStock(request);
    }
    @GetMapping("/getLastStockCondition")
    @ApiOperation(value = "底仓指令条件返回")
    @WebLogger
    public ResponseInfo getLastStockCondition(){
        return  pcLastStockService.getLastStockCondition();
    }
    @WebLogger
    @ApiOperation("号码明细/收发料明细")
    @GetMapping("/getPcLastStockSizeDetail")
    public ResponseInfo getPcLastStockSizeDetail(@RequestParam("lotNo") String lotNo, @RequestParam("partName") String partName){
        return pcLastStockService.getPcLastStockSizeDetail(lotNo,partName);
    }

    @ApiOperation("库存资料/入库资料/发料资料")
    @PostMapping("/getStockMessageInOut")
    @WebLogger
    public ResponseInfo getStockMessageInOut(@RequestBody PcSoleStockMessageRequest request){
        return pcLastStockService.getStockMessageInOut(request);
    }

    //导出收发料报表
    @WebLogger
    @PostMapping("/downloadStockInOut")
    @ApiOperation("导出收发料报表")
    public void downloadStockInOut(HttpServletResponse response,@RequestBody PcSoleStockMessageRequest req) throws UnsupportedEncodingException {
        pcLastStockService.downloadStockInOut(response,req);
    }
    @ApiOperation("面底配套资料查询")
    @PostMapping("/getSoleSupporting")
    @WebLogger
    public ResponseInfo getSoleSupporting(@RequestBody SoleSupportingInformationRequest request) throws ExecutionException, InterruptedException {
        return pcLastStockService.getSoleSupporting(request);
    }
    @ApiOperation("面底配套明细")
    @GetMapping("getSoleSupportingDetail/{lotNo}")
    @WebLogger
    public ResponseInfo getSoleSupportingDetail(@PathVariable String lotNo){
        return pcLastStockService.getSoleSupportingDetail(lotNo);
    }
}
